package com.dorm.cj.extension.scheduleTask;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.time.LocalTime;

@Configuration
@EnableScheduling
public class TestSchedulingConfigurer implements SchedulingConfigurer {
    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.addCronTask(
                () -> {
                    System.out.println("======cronTask=======" + LocalTime.now());
                }, "0/2 * * * * ?"
        );
    }
}
